import request from "@/utils/request";
import type { AxiosPromise } from "axios";
//获取所有模块数据 （包含status = ‘1’的）
export const _getAllModules = async (): Promise<AxiosPromise> => {
  const response = await request({
    url: '/menu/menu-setting-modules',
    method: 'GET',
  });
  return response; // Assuming the response contains the data in this format
}
//根据模块id 获取模块下所有菜单数据
export const _getMenusByModuleId = async (moduleId: string): Promise<AxiosPromise> => {
  const response = await request({
    url: '/menu/query-menu-list-by-moduleId',
    method: 'GET',
    params: {
      moduleId: moduleId
    }
  });
  return response; // Assuming the response contains the data in this format
}


export const _getMenuInfoById = async (menuId: string): Promise<AxiosPromise> => {
  const response = await request({
    url: '/menu/query-menu-byId',
    method: 'GET',
    params: {
      menuId: menuId
    }
  });
  return response; // Assuming the response contains the data in this format
}


//获取所有菜单数据
export const _getAllMenuList = async (): Promise<AxiosPromise> => {
  const response = await request({
    url: '/menu/query-all-menu-tree',
    method: 'GET',
  });
  return response; // Assuming the response contains the data in this format
}

export const _getSettingMenuTypeConfig = async (moduleKey: string, menuType: string): Promise<AxiosPromise> => {
  const response = await request({
    url: '/menu/query-setting-menu-type-config',
    method: 'GET',
    params: {
      moduleKey: moduleKey,
      type: menuType
    }
  });
  return response; // Assuming the response contains the data in this format
}


export const _saveMenuInfo = async(param : object) : Promise<AxiosPromise> =>{
  const response = await request({
    url: '/menu/insert',
    method: 'POST',
    data: param
  });
  return response;
}

export const _updateMenuInfo = async(param : object) : Promise<AxiosPromise> =>{
  const response = await request({
    url: '/menu/modify',
    method: 'POST',
    data: param
  });
  return response;
}









export interface MenuInfo {
  id?: string,
  menuName?: string,
  parentId?: number,
  moduleKey?: string,
  orderNum?: number,
  path?: string,
  component?: string,
  queryParam?: string,
  isFrame?: number,
  isCache?: number,
  menuType?: string,
  visible?: string,
  status?: string,
  perms?: string,
  icon?: string,
  createDept?: number,
  remark?: string,
  delFlag?: string
}
